package com.lbd.dynamicCode.dao;

import com.lbd.dynamicCode.bean.MsgSendRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.io.Serializable;

/**
 * Created by zzl on 2017/11/19.
 */
public interface DynamicCodeRepository
        extends PagingAndSortingRepository<MsgSendRecord, Serializable>, JpaSpecificationExecutor<MsgSendRecord> {
    /**
     * 保存短信消息并返回ID
     * @param record
     * @return
     */
    @Override
    MsgSendRecord save(MsgSendRecord record);

    /**
     * @param shortLink 短链接
     * @param landUrl 落地页
     * @param id 主键标识
     * @return
     */
    @Modifying
    @Query("update  com.lbd.dynamicCode.bean.MsgSendRecord set shortLink=:shortLink,landUrl=:landUrl where id = :id")
    int updateRecord(@Param("shortLink")String shortLink,@Param("landUrl")String landUrl,@Param("id")String id);
}
